Fetch invoices
Step 1: Request a token
To fetch invoices a token is needed. You create tokens with the Create Token call. Tokens can be set to be valid for a period of time or set to never expire. You need to decide if you want to store the token of each company in your system, or request a new one for each communication session. We recommend that tokens are created with a short TTL of 10 minutes.
Request Example
POST /v1/api/clientTokens/create HTTP/1.1
APIKey: --YOUR API KEY HERE--
Content-Type: application/json; charset=utf-8
Host: testapi.inexchange.se
Content-Length: 183
Expect: 100-continue
{
"erpId": "635604692357550266",
"validTo": "2026-05-26T12:54:10"
}
Response Example
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 63
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
Date: Tue, 26 May 2026 12:54:10 GMT
{
"token": "--CLIENT TOKEN HERE--"
}
Step 2: Fetch inbound invoices
In order to fetch all unhandled inbound invoices make a Incoming documents call. This will return a list of invoice metadata of invoices that previously havent been marked as handled. This means invoices will keep to appear in this list as available to fetch until they have been marked as handled. See step 4. This can be overridden by providing the sequenceNo query parameter. This will mean that an assumption is made that documents are tracked manually and this the handled flag is ignored.
Request Example
GET /v1/api/documents/incoming?type=invoice HTTP/1.1
Host: testapi.inexchange.se
ClientToken: "--CLIENT TOKEN HERE--"
Accept: */*
Content-Length: 0
Response Example
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 2
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 26 May 2026 12:54:10 GMT
{
"documents": [
{
"id": "b52566be-7e82-43f3-bd54-00f6c1111111",
"documentType": "Invoice",
"documentFormat": "Invoice_Demo_Format",
"infoUrl": "https://testapi.inexchange.se/v1/api/documents/b52566be-7e82-43f3-bd54-00f6c1111111/info",
"downloadUrl": "https://testapi.inexchange.se/v1/api/documents/b52566be-7e82-43f3-bd54-00f6c1111111",
"sequenceNo": 111
},
.....
],
"total": 126
}
Step 3: Download listed invoices
After getching the list of invoices that are ready for download you iterate over them by following the downloadUrl in the response in Step 2 or just issue a call to Download Incoming using the id from the documents list. This will return the document together with some metadata in the header.
Request Example
GET /v1/api/documents/b52566be-7e82-43f3-bd54-00f6c1111111 HTTP/1.1
Host: testapi.inexchange.se
ClientToken: "--CLIENT TOKEN HERE--"
Accept: */*
Response Example
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 58791
Content-Type: application/zip
Content-Disposition: attachment; filename=invoice_demo.zip
X-Filename: invoice_demo.zip
X-Document-Format: Invoice_Demo_Format
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 26 May 2026 12:54:10 GMT
Step 4: Mark invoice as handled
When the invoice is concidered fetched and downloaded successfully the invoice may be marked as handled. This makes the invoice not appear as new to download in the Incoming documents call when its called without a sequence number.
Request Example
POST /v1/api/documents/handled HTTP/1.1
Host: testapi.inexchange.se
ClientToken: "--CLIENT TOKEN HERE--"
Content-Type: application/json
Accept: */*
{
"documents": [
"b52566be-7e82-43f3-bd54-00f6c1111111"
]
}
Response Example
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 0
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 26 May 2026 12:54:10 GMT